package com.yugao.fintech.framework.samples.core;

import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.RandomUtil;
import com.yugao.fintech.framework.assistant.core.exception.BizException;
import com.yugao.fintech.framework.core.response.Resp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ResponseFormatController {

    @GetMapping("/resp_format")
    public Resp<?> test() {
        boolean isError = RandomUtil.randomInt(1, 10) > 5;
        if (isError) {
            throw new BizException("业务异常");
        }
        return Resp.ok(UUID.randomUUID().toString());
    }

    public static class TestDO {
        private String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    @GetMapping("/test5")
    public Resp<TestDO> test5() {
        TestDO test = new TestDO();
        test.setName("tom");
        return Resp.ok(test);
    }
}
